#ifndef DEF_COMMON_H
#define DEF_COMMON_H

#include <cstdio>
#include <string>

using namespace std;

static const int N_LAYER = 3;
static const int L_COLL  = 0;
static const int L_SOL   = 1;
static const int L_TOUR  = 2;

static const int RIGHT = 0;
static const int LEFT  = 1;
static const int UP    = 2;
static const int DOWN  = 3;

static const int TILE_DIM    = 32;
static const int MAP_DIM_MAX = 20;

static const string map_path("../datas/maps/");
static const string tileset_def_path("../datas/tilesets/");

static int dir[4][2] = {{0,1},{0,-1},{-1,0},{1,0}}; 

struct pix_coord
{
   int x,y;
   pix_coord(int x=0, int y=0) : x(x), y(y) {}
};

struct map_coord
{
   int iLig, iCol;
   map_coord(int iLig=0, int iCol=0) : iLig(iLig), iCol(iCol) {}
};

struct map_dim
{
   int height, width;
   map_dim(int height=0, int width=0) : height(height), width(width) {}
};

struct pix_dim
{
   int width, height;
   pix_dim(int width=0, int height=0) : width(width), height(height) {}
};

struct vec
{
   int depX, depY;
   vec() : depX(0), depY(0) {}
   vec(pix_coord a, pix_coord b) : depX(b.x-a.x), depY(b.y-a.y) {}
   vec(map_coord a, map_coord b) : depX(b.iCol-a.iCol), depY(b.iLig-b.iLig) {}
};

static map_coord indice_to_map_coord(int i, int width)
{
   return map_coord(i/width,i%width);
}

static int char_to_int(char a)
{
   return a-'0';
}

static int string_to_int(string a)
{
   int coeff = 1;
   for(int i = 0 ; i < a.size()-1 ; i++)
      coeff *= 10;
      
   int res = 0;
   
   for(int i = 0 ; i < a.size() ; i++)
   {
      res += char_to_int(a[i])*coeff;
      coeff/=10;
   }
   
   return res;
}



#endif
